package site.icesky.springboot.mybatis.service.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import site.icesky.springboot.mybatis.dao.mapper.UsersMapper;
import site.icesky.springboot.mybatis.service.UsersService;

import site.icesky.springboot.mybatis.dao.pojo.Users;

import java.util.List;

/**
 * @ClassName: UsersServiceImpl <br>
 * @Description: 实现用户操作接口 <br>
 * @Package: com.isstudy.s12mybastis.service.impl <br>
 * @author: suitianmou <br>
 * @Date: 2020/5/13-00:20 <br>
 * @version: 1.0 <br>
 * @see <br>
 * @since (从产品的哪一个版本此类被添加进来 ( 可选))<br>
 * 修改历史: <br>
 * 修改时间             修改人           版本变更           修改说明<br>
 * -----------------------------------------------------<br>
 * <br>
 */
@Service
@Transactional
public class UsersServiceImpl implements UsersService {

    @Autowired
    private UsersMapper usersMapper;

    @Override
    public void addUser(Users users) {
        this.usersMapper.insertUser(users);
    }

    @Override
    public List<Users> findAllUsers() {

        return this.usersMapper.selectUsersAll();
    }

    @Override
    public Users findUserById(Integer id ) {
        return this.usersMapper.selectByPrimaryKey(id );
    }

    @Override
    public void updateUser(Users user) {
        this.usersMapper.updateByPrimaryKey(user);
    }

    @Override
    public void deleteUserById(Integer id) {
        this.usersMapper.deleteByPrimaryKey(id);
    }
}
